package com.design.working.service.impl;

import com.design.working.dao.CounselorDAO;
import com.design.working.dao.impl.CounselorDAOImpl;
import com.design.working.dto.counselor.CounselorHandleStudentApplicationDTO;
import com.design.working.dto.PageControlDTO;
import com.design.working.dto.counselor.SearchCounselorStudentAttendanceDTO;
import com.design.working.po.StudentApplicationDetailPO;
import com.design.working.po.StudentApplicationExaminationPO;
import com.design.working.po.StudentMsgPO;
import com.design.working.po.counselor.CounselorSelectStudentApplicationPO;
import com.design.working.po.counselor.CounselorStudentAttendanceRecordPO;
import com.design.working.service.CounselorService;
import com.design.working.vo.*;
import com.design.working.vo.admin.StudentApplicationDetailVO;
import com.design.working.vo.admin.StudentApplicationExaminationVO;
import com.design.working.vo.admin.StudentMsgVO;
import com.design.working.vo.counselor.CounselorCollegeStudentInfoVO;
import com.design.working.vo.counselor.CounselorHandleStudentWorkApplicationVO;
import com.design.working.vo.counselor.CounselorSelectStudentApplicationVO;
import com.design.working.vo.counselor.CounselorStudentAttendanceRecordVO;
import com.design.working.vo.student.JobSelectionVO;

import java.util.ArrayList;
import java.util.List;

import static com.design.working.enums.OperationEnum.NO_PAGE;

/**
 * 学生端服务层
 */
public class CounselorServiceImpl implements CounselorService {

    /**
     * 秋季学期, 1
     */
    private static final String AUTUMN_TERM = "1";

    /**
     * 批准/是, 1
     */
    private static final int APPROVED = 1;

    /**
     * 拒绝（负数表示）, -1
     */
    private static final int REJECT_IN_MINUS = -1;

    /**
     * 否（0表示）, 0
     */
    private static final int REJECT_IN_ZERO = 0;

    /**
     * 缺勤, 0
     */
    private static final int NOT_ATTEND = 0;

    /**
     * 出勤, 1
     */
    private static final int ATTEND = 1;

    /**
     * 请假, 2
     */
    private static final int LEAVE = 2;

    /**
     * 男，M
     */
    private static final String MALE = "M";

    /**
     * 女，F
     */
    private static final String FEMALE = "F";

    /**
     * 无审核员, "无审核员"
     */
    private static final String NO_EDITOR = "无审核员";

    /**
     * 无意见, "无意见"
     */
    private static final String NO_TEXT = "无意见";

    /**
     * 未处理, "未处理"
     */
    private static final String NO_HANDLE_STRING = "未处理";

    /**
     * 未处理, 0
     */
    private static final int NOT_HANDLED = 0;

    /**
     * 辅导员已处理, 1
     */
    private static final int COUNSELOR_HANDLED = 1;

    /**
     * 部门员工已处理, 2
     */
    private static final int DEPT_HANDLED = 2;

    private final CounselorDAO counselorDAO = new CounselorDAOImpl();

    /**
     * 查找本院未审批的学生岗位申请记录
     *
     * @param uid            辅导员工号
     * @param pageControlDTO 分页信息
     * @return 查询到的本院未审批的学生岗位申请记录
     */
    @Override
    public ResponseVO<List<CounselorHandleStudentWorkApplicationVO>> selectStudentWorkApplication(Integer uid, PageControlDTO pageControlDTO) {

        int size = counselorDAO.selectStudentWorkApplication(uid, NO_PAGE.getVal(), pageControlDTO.getLimit()).size();
        if (size == 0){
            return ResponseVO.error("暂时没有要处理的学生申请！");
        }

        // 访问数据库
        int page = (pageControlDTO.getPage() - 1) * pageControlDTO.getLimit();
        List<CounselorHandleStudentWorkApplicationVO> list = counselorDAO.selectStudentWorkApplication(uid, page, pageControlDTO.getLimit());
        return ResponseVO.success(size, list);
    }

    /**
     * 审批学生的岗位申请
     *
     * @param uid 辅导员工号
     * @param counselorCheckApplicationDTO 辅导员对学生申请记录的审批内容
     */
    @Override
    public void insertStudentApplicationHanding(Integer uid, CounselorHandleStudentApplicationDTO counselorCheckApplicationDTO) {

        int id = counselorDAO.selectCounselorId(uid);
        counselorDAO.insertStudentApplicationHanding(id, counselorCheckApplicationDTO);
    }

    /**
     * 查找申请表中学生申请工作填写的个人信息
     *
     * @param smtId 学生申请工作表中对应的个人信息记录id
     * @return 学生申请工作填写的个人信息
     */
    @Override
    public ResponseVO<StudentApplicationDetailVO> selectStudentApplicationDetail(Integer smtId) {

        StudentApplicationDetailPO studentApplicationDetailPO = counselorDAO.selectStudentApplicationDetail(smtId);
        StudentApplicationDetailVO studentApplicationDetailVO = new StudentApplicationDetailVO();

        studentApplicationDetailVO.setPhone(studentApplicationDetailPO.getPhone());
        studentApplicationDetailVO.setEmail(studentApplicationDetailPO.getEmail());
        studentApplicationDetailVO.setPoliticalStatus(studentApplicationDetailPO.getPoliticalStatus());

        String needyStudent = null;
        switch (studentApplicationDetailPO.getNeedyStudent()) {
            case REJECT_IN_ZERO:
                needyStudent = "否";
                break;
            case APPROVED:
                needyStudent = "是";
                break;
            default:
        }
        studentApplicationDetailVO.setNeedyStudent(needyStudent);

        studentApplicationDetailVO.setDorm(studentApplicationDetailPO.getDorm());
        studentApplicationDetailVO.setStrength(studentApplicationDetailPO.getStrength());
        studentApplicationDetailVO.setFreeTime(studentApplicationDetailPO.getFreeTime());

        return ResponseVO.success(studentApplicationDetailVO);
    }

    /**
     * （申请岗位）查找全部岗位
     *
     * @param place          需要查询的岗位所属的行政分类
     * @param pageControlDTO 分页信息
     * @return 查询到的岗位
     */
    @Override
    public ResponseVO<List<JobSelectionVO>> selectJob(String place, PageControlDTO pageControlDTO) {

        // 将前端参数转为数据库对应字段的值
        String substitution = null;
        switch (place) {
            case "classes":
                substitution = "教学区";
                break;
            case "admin":
                substitution = "行政区";
                break;
            case "edu":
                substitution = "教务";
                break;
            case "library":
                substitution = "图书馆";
                break;
            case "service":
                substitution = "后勤";
                break;
            default:
        }

        int size = counselorDAO.selectJob(substitution,-1, pageControlDTO.getLimit()).size();
        if (size == 0) {
            return ResponseVO.error("暂时没有岗位！");
        }

        // 访问数据库
        int page = (pageControlDTO.getPage() - 1) * pageControlDTO.getLimit();
        List<JobSelectionVO> list = counselorDAO.selectJob(substitution, page, pageControlDTO.getLimit());

        return ResponseVO.success(size, list);
    }

    /**
     * 查找本院学生信息
     *
     * @param uid            辅导员工号
     * @param pageControlDTO 分页信息
     * @return 查询到的本院学生信息
     */
    @Override
    public ResponseVO<List<CounselorCollegeStudentInfoVO>> selectStudentInfo(Integer uid, PageControlDTO pageControlDTO) {

        int size = counselorDAO.selectStudentInfo(uid, NO_PAGE.getVal(), pageControlDTO.getLimit()).size();
        // 如果本院没有学生信息
        if (size == 0) {
            return ResponseVO.error("本院暂时没有学生信息！");
        }

        // 访问数据库
        int page = (pageControlDTO.getPage() - 1) * pageControlDTO.getLimit();
        List<CounselorCollegeStudentInfoVO> list = counselorDAO.selectStudentInfo(uid, page, pageControlDTO.getLimit());
        return ResponseVO.success(size, list);
    }

    /**
     * 通过学号姓名查找本院学生信息
     *
     * @param uid            辅导员工号
     * @param pageControlDTO 分页信息
     * @param stuUid         学生学号
     * @param studentName    学生姓名
     * @return 查询到的本院学生信息
     */
    @Override
    public ResponseVO<List<CounselorCollegeStudentInfoVO>> selectStudentInfoByName(Integer uid, PageControlDTO pageControlDTO, String stuUid, String studentName) {

        int size = counselorDAO.selectStudentInfoByName(uid, NO_PAGE.getVal(), pageControlDTO.getLimit(), stuUid, studentName).size();
        // 如果本院没有该生的学生信息
        if (size == 0) {
            return ResponseVO.error("本院暂时没有该生信息！");
        }

        // 访问数据库
        int page = (pageControlDTO.getPage() - 1) * pageControlDTO.getLimit();
        List<CounselorCollegeStudentInfoVO> list = counselorDAO.selectStudentInfoByName(uid, page, pageControlDTO.getLimit(), stuUid, studentName);
        return ResponseVO.success(size, list);
    }

    /**
     * 查询学生详细信息
     *
     * @param uid 学生学号
     * @return 学生个人详细信息
     */
    @Override
    public ResponseVO<StudentMsgVO> selectStudentMsg(Integer uid) {

        StudentMsgPO studentMsgPO = counselorDAO.selectStudentMsg(uid);
        StudentMsgVO studentMsgVO = new StudentMsgVO();

        String gender = null;
        switch (studentMsgPO.getGender()) {
            case MALE:
                gender = "男";
                break;
            case FEMALE:
                gender = "女";
                break;
            default:
        }
        studentMsgVO.setGender(gender);

        studentMsgVO.setPhone(studentMsgPO.getPhone());
        studentMsgVO.setEmail(studentMsgPO.getEmail());
        studentMsgVO.setPoliticalStatus(studentMsgPO.getPoliticalStatus());

        String needyStudent = null;
        switch (studentMsgPO.getNeedStudent()) {
            case REJECT_IN_ZERO:
                needyStudent = "否";
                break;
            case APPROVED:
                needyStudent = "是";
                break;
            default:
        }
        studentMsgVO.setNeedStudent(needyStudent);

        studentMsgVO.setDorm(studentMsgPO.getDorm());
        studentMsgVO.setStrength(studentMsgPO.getStrength());

        return ResponseVO.success(studentMsgVO);
    }

    /**
     * 查询本院学生考勤记录
     *
     * @param uid            辅导员工号
     * @param pageControlDTO 分页信息
     * @return 学生考勤记录
     */
    @Override
    public ResponseVO<List<CounselorStudentAttendanceRecordVO>> selectCollegeStudentAttendance(Integer uid, PageControlDTO pageControlDTO) {

        int size = counselorDAO.selectCollegeStudentAttendance(uid, NO_PAGE.getVal(), pageControlDTO.getLimit()).size();
        // 如果没有本院学生的考勤记录
        if (size == 0) {
            return ResponseVO.error("暂时没有本院学生的考勤记录！");
        }

        // 访问数据库
        int page = (pageControlDTO.getPage() - 1) * pageControlDTO.getLimit();
        List<CounselorStudentAttendanceRecordPO> temp = counselorDAO.selectCollegeStudentAttendance(uid, page, pageControlDTO.getLimit());

        List<CounselorStudentAttendanceRecordVO> list = new ArrayList<>();
        // 转换数据
        for (CounselorStudentAttendanceRecordPO counselorStudentAttendanceRecordPO : temp) {

            CounselorStudentAttendanceRecordVO counselorStudentAttendanceRecordVO = new CounselorStudentAttendanceRecordVO();

            counselorStudentAttendanceRecordVO.setUid(counselorStudentAttendanceRecordPO.getUid());
            counselorStudentAttendanceRecordVO.setName(counselorStudentAttendanceRecordPO.getName());

            String year = counselorStudentAttendanceRecordPO.getYear() + "-" + (counselorStudentAttendanceRecordPO.getYear() + 1);
            String term = AUTUMN_TERM.equals(String.valueOf(counselorStudentAttendanceRecordPO.getTerm())) ? "秋冬学期" : "春夏学期";
            counselorStudentAttendanceRecordVO.setYear(year);
            counselorStudentAttendanceRecordVO.setTerm(term);

            counselorStudentAttendanceRecordVO.setDept(counselorStudentAttendanceRecordPO.getDept());
            counselorStudentAttendanceRecordVO.setWorkName(counselorStudentAttendanceRecordPO.getWorkName());
            counselorStudentAttendanceRecordVO.setEmployer(counselorStudentAttendanceRecordPO.getEmployer());
            counselorStudentAttendanceRecordVO.setDate(counselorStudentAttendanceRecordPO.getDate());

            String workType = null;
            switch (counselorStudentAttendanceRecordPO.getType()) {
                case NOT_ATTEND:
                    workType = "缺勤";
                    break;
                case ATTEND:
                    workType = "出勤";
                    break;
                case LEAVE:
                    workType = "请假";
                    break;
                default:
            }
            counselorStudentAttendanceRecordVO.setType(workType);

            list.add(counselorStudentAttendanceRecordVO);
        }

        return ResponseVO.success(size, list);
    }

    /**
     * 通过学号姓名查询本院学生考勤记录
     *
     * @param uid            辅导员工号
     * @param pageControlDTO 分页信息
     * @param searchDTO      搜索的信息
     * @return 学生考勤记录
     */
    @Override
    public ResponseVO<List<CounselorStudentAttendanceRecordVO>> selectCollegeStudentAttendanceByLimit(Integer uid, PageControlDTO pageControlDTO, SearchCounselorStudentAttendanceDTO searchDTO) {

        int size;
        // 如果不走时间查询
        if (searchDTO.getBeginDate() == null && searchDTO.getEndDate() == null) {
            size = counselorDAO.selectCollegeStudentAttendanceByName(uid, NO_PAGE.getVal(), pageControlDTO.getLimit(), searchDTO).size();
        } else {
            size = counselorDAO.selectCollegeStudentAttendanceByTime(uid, NO_PAGE.getVal(), pageControlDTO.getLimit(), searchDTO).size();
        }

        // 如果没有考勤记录
        if (size == 0) {
            return ResponseVO.error("暂时没有考勤记录！");
        }

        // 访问数据库
        int page = (pageControlDTO.getPage() - 1) * pageControlDTO.getLimit();

        List<CounselorStudentAttendanceRecordPO> temp;
        // 如果不走时间查询
        if (searchDTO.getBeginDate() == null && searchDTO.getEndDate() == null) {
            temp = counselorDAO.selectCollegeStudentAttendanceByName(uid, page, pageControlDTO.getLimit(), searchDTO);
        } else {
            temp = counselorDAO.selectCollegeStudentAttendanceByTime(uid, page, pageControlDTO.getLimit(), searchDTO);
        }

        List<CounselorStudentAttendanceRecordVO> list = new ArrayList<>();

        // 转换数据
        for (CounselorStudentAttendanceRecordPO counselorStudentAttendanceRecordPO : temp) {

            CounselorStudentAttendanceRecordVO counselorStudentAttendanceRecordVO = new CounselorStudentAttendanceRecordVO();

            counselorStudentAttendanceRecordVO.setUid(counselorStudentAttendanceRecordPO.getUid());
            counselorStudentAttendanceRecordVO.setName(counselorStudentAttendanceRecordPO.getName());

            String year = counselorStudentAttendanceRecordPO.getYear() + "-" + (counselorStudentAttendanceRecordPO.getYear() + 1);
            String term = AUTUMN_TERM.equals(String.valueOf(counselorStudentAttendanceRecordPO.getTerm())) ? "秋冬学期" : "春夏学期";
            counselorStudentAttendanceRecordVO.setYear(year);
            counselorStudentAttendanceRecordVO.setTerm(term);

            counselorStudentAttendanceRecordVO.setDept(counselorStudentAttendanceRecordPO.getDept());
            counselorStudentAttendanceRecordVO.setWorkName(counselorStudentAttendanceRecordPO.getWorkName());
            counselorStudentAttendanceRecordVO.setEmployer(counselorStudentAttendanceRecordPO.getEmployer());
            counselorStudentAttendanceRecordVO.setDate(counselorStudentAttendanceRecordPO.getDate());

            String workType = null;
            switch (counselorStudentAttendanceRecordPO.getType()) {
                case NOT_ATTEND:
                    workType = "缺勤";
                    break;
                case ATTEND:
                    workType = "出勤";
                    break;
                case LEAVE:
                    workType = "请假";
                    break;
                default:
            }
            counselorStudentAttendanceRecordVO.setType(workType);

            list.add(counselorStudentAttendanceRecordVO);
        }

        return ResponseVO.success(size, list);
    }

    /**
     * 查询本院学生申请岗位的信息
     * @param uid            辅导员工号
     * @param pageControlDTO 分页信息
     * @return 学生申请岗位的信息
     */
    @Override
    public ResponseVO<List<CounselorSelectStudentApplicationVO>> selectStudentApplication(Integer uid, PageControlDTO pageControlDTO) {

        int size = counselorDAO.selectStudentApplication(uid, NO_PAGE.getVal(), pageControlDTO.getLimit()).size();
        // 如果没有本院学生的申请记录
        if (size == 0) {
            return ResponseVO.error("暂时没有本院学生的申请记录！");
        }

        // 访问数据库
        int page = (pageControlDTO.getPage() - 1) * pageControlDTO.getLimit();
        List<CounselorSelectStudentApplicationPO> temp = counselorDAO.selectStudentApplication(uid, page, pageControlDTO.getLimit());

        List<CounselorSelectStudentApplicationVO> list = new ArrayList<>();
        // 转换数据
        for (CounselorSelectStudentApplicationPO counselorSelectStudentApplicationPO : temp) {

            CounselorSelectStudentApplicationVO counselorSelectStudentApplicationVO = new CounselorSelectStudentApplicationVO();

            counselorSelectStudentApplicationVO.setUid(counselorSelectStudentApplicationPO.getUid());
            counselorSelectStudentApplicationVO.setName(counselorSelectStudentApplicationPO.getName());

            String year = counselorSelectStudentApplicationPO.getYear() + "-" + (counselorSelectStudentApplicationPO.getYear() + 1);
            String term = AUTUMN_TERM.equals(String.valueOf(counselorSelectStudentApplicationPO.getTerm())) ? "秋冬学期" : "春夏学期";
            counselorSelectStudentApplicationVO.setYear(year);
            counselorSelectStudentApplicationVO.setTerm(term);

            counselorSelectStudentApplicationVO.setDept(counselorSelectStudentApplicationPO.getDept());
            counselorSelectStudentApplicationVO.setWorkName(counselorSelectStudentApplicationPO.getWorkName());

            String type = null;
            switch (counselorSelectStudentApplicationPO.getType()) {
                case NOT_HANDLED:
                    type = "未处理";
                    break;
                case APPROVED:
                    type = "批准";
                    break;
                case REJECT_IN_MINUS:
                    type = "拒绝";
                    break;
                default:
            }
            counselorSelectStudentApplicationVO.setType(type);

            counselorSelectStudentApplicationVO.setWorkDetail(counselorSelectStudentApplicationPO.getWorkDetail());
            counselorSelectStudentApplicationVO.setId(counselorSelectStudentApplicationPO.getId());
            counselorSelectStudentApplicationVO.setSmtId(counselorSelectStudentApplicationPO.getSmtId());

            list.add(counselorSelectStudentApplicationVO);
        }

        return ResponseVO.success(size, list);
    }

    /**
     * 通过学号姓名查询本院学生申请岗位的信息
     * @param uid            辅导员工号
     * @param pageControlDTO 分页信息
     * @param stuUid         学生学号
     * @param studentName    学生姓名
     * @return 学生申请岗位的信息
     */
    @Override
    public ResponseVO<List<CounselorSelectStudentApplicationVO>> selectStudentApplicationByName(Integer uid, PageControlDTO pageControlDTO, String stuUid, String studentName) {

        int size = counselorDAO.selectStudentApplicationByName(uid, NO_PAGE.getVal(), pageControlDTO.getLimit(), stuUid, studentName).size();
        // 如果没有该生的申请记录
        if (size == 0) {
            return ResponseVO.error("暂时没有该生的申请记录！");
        }

        // 访问数据库
        int page = (pageControlDTO.getPage() - 1) * pageControlDTO.getLimit();
        List<CounselorSelectStudentApplicationPO> temp = counselorDAO.selectStudentApplicationByName(uid, page, pageControlDTO.getLimit(), stuUid, studentName);

        List<CounselorSelectStudentApplicationVO> list = new ArrayList<>();
        // 转换数据
        for (CounselorSelectStudentApplicationPO counselorSelectStudentApplicationPO : temp) {

            CounselorSelectStudentApplicationVO counselorSelectStudentApplicationVO = new CounselorSelectStudentApplicationVO();

            counselorSelectStudentApplicationVO.setUid(counselorSelectStudentApplicationPO.getUid());
            counselorSelectStudentApplicationVO.setName(counselorSelectStudentApplicationPO.getName());

            String year = counselorSelectStudentApplicationPO.getYear() + "-" + (counselorSelectStudentApplicationPO.getYear() + 1);
            String term = AUTUMN_TERM.equals(String.valueOf(counselorSelectStudentApplicationPO.getTerm())) ? "秋冬学期" : "春夏学期";
            counselorSelectStudentApplicationVO.setYear(year);
            counselorSelectStudentApplicationVO.setTerm(term);

            counselorSelectStudentApplicationVO.setDept(counselorSelectStudentApplicationPO.getDept());
            counselorSelectStudentApplicationVO.setWorkName(counselorSelectStudentApplicationPO.getWorkName());

            String type = null;
            switch (counselorSelectStudentApplicationPO.getType()) {
                case NOT_HANDLED:
                    type = "未处理";
                    break;
                case APPROVED:
                    type = "批准";
                    break;
                case REJECT_IN_MINUS:
                    type = "拒绝";
                    break;
                default:
            }
            counselorSelectStudentApplicationVO.setType(type);

            counselorSelectStudentApplicationVO.setWorkDetail(counselorSelectStudentApplicationPO.getWorkDetail());
            counselorSelectStudentApplicationVO.setId(counselorSelectStudentApplicationPO.getId());
            counselorSelectStudentApplicationVO.setSmtId(counselorSelectStudentApplicationPO.getSmtId());

            list.add(counselorSelectStudentApplicationVO);
        }

        return ResponseVO.success(size, list);
    }

    /**
     * 查询学生岗位申请的记录
     * @param swaId 学生岗位申请表id
     * @return 学生岗位申请审批记录
     */
    @Override
    public ResponseVO<StudentApplicationExaminationVO> selectStuAppExamination(Integer swaId) {

        int handleType = counselorDAO.isHandleStuApp(swaId);
        StudentApplicationExaminationVO studentApplicationExaminationVO = new StudentApplicationExaminationVO();

        if (handleType == NOT_HANDLED){
            //手动赋值
            studentApplicationExaminationVO.setCounselor(NO_EDITOR);
            studentApplicationExaminationVO.setCounselorText(NO_TEXT);
            studentApplicationExaminationVO.setCounselorPassed(NO_HANDLE_STRING);
            studentApplicationExaminationVO.setDeptEmployee(NO_EDITOR);
            studentApplicationExaminationVO.setDeptEmployeeText(NO_TEXT);
            studentApplicationExaminationVO.setDeptEmployeePassed(NO_HANDLE_STRING);
            studentApplicationExaminationVO.setAdmin(NO_EDITOR);
            studentApplicationExaminationVO.setAdminText(NO_TEXT);
            studentApplicationExaminationVO.setAdminPassed(NO_HANDLE_STRING);

            return ResponseVO.success(studentApplicationExaminationVO);
        }

        if (handleType == COUNSELOR_HANDLED){
            StudentApplicationExaminationPO studentApplicationExaminationPO = counselorDAO.selectStuAppExamination0(swaId);

            studentApplicationExaminationVO.setCounselor(studentApplicationExaminationPO.getCounselor());
            studentApplicationExaminationVO.setCounselorText(studentApplicationExaminationPO.getCounselorText());
            String counselorPassed = null;
            switch (studentApplicationExaminationPO.getCounselorPassed()) {
                case NOT_HANDLED:
                    counselorPassed = "未处理";
                    break;
                case REJECT_IN_MINUS:
                    counselorPassed = "拒绝";
                    break;
                case APPROVED:
                    counselorPassed = "批准";
                    break;
                default:
            }
            studentApplicationExaminationVO.setCounselorPassed(counselorPassed);

            //手动赋值
            studentApplicationExaminationVO.setDeptEmployee(NO_EDITOR);
            studentApplicationExaminationVO.setDeptEmployeeText(NO_TEXT);
            studentApplicationExaminationVO.setDeptEmployeePassed(NO_HANDLE_STRING);
            studentApplicationExaminationVO.setAdmin(NO_EDITOR);
            studentApplicationExaminationVO.setAdminText(NO_TEXT);
            studentApplicationExaminationVO.setAdminPassed(NO_HANDLE_STRING);

            return ResponseVO.success(studentApplicationExaminationVO);
        }

        if (handleType == DEPT_HANDLED){
            StudentApplicationExaminationPO studentApplicationExaminationPO = counselorDAO.selectStuAppExamination1(swaId);

            studentApplicationExaminationVO.setCounselor(studentApplicationExaminationPO.getCounselor());
            studentApplicationExaminationVO.setCounselorText(studentApplicationExaminationPO.getCounselorText());
            String counselorPassed = null;
            switch (studentApplicationExaminationPO.getCounselorPassed()) {
                case NOT_HANDLED:
                    counselorPassed = "未处理";
                    break;
                case REJECT_IN_MINUS:
                    counselorPassed = "拒绝";
                    break;
                case APPROVED:
                    counselorPassed = "批准";
                    break;
                default:
            }
            studentApplicationExaminationVO.setCounselorPassed(counselorPassed);

            studentApplicationExaminationVO.setDeptEmployee(studentApplicationExaminationPO.getDeptEmployee());
            studentApplicationExaminationVO.setDeptEmployeeText(studentApplicationExaminationPO.getDeptEmployeeText());
            String deptEmployeePassed = null;
            switch (studentApplicationExaminationPO.getDeptEmployeePassed()) {
                case NOT_HANDLED:
                    deptEmployeePassed = "未处理";
                    break;
                case REJECT_IN_MINUS:
                    deptEmployeePassed = "拒绝";
                    break;
                case APPROVED:
                    deptEmployeePassed = "批准";
                    break;
                default:
            }
            studentApplicationExaminationVO.setDeptEmployeePassed(deptEmployeePassed);

            //手动赋值
            studentApplicationExaminationVO.setAdmin(NO_EDITOR);
            studentApplicationExaminationVO.setAdminText(NO_TEXT);
            studentApplicationExaminationVO.setAdminPassed(NO_HANDLE_STRING);

            return ResponseVO.success(studentApplicationExaminationVO);
        }

        StudentApplicationExaminationPO studentApplicationExaminationPO = counselorDAO.selectStuAppExamination(swaId);

        studentApplicationExaminationVO.setCounselor(studentApplicationExaminationPO.getCounselor());
        studentApplicationExaminationVO.setCounselorText(studentApplicationExaminationPO.getCounselorText());

        String counselorPassed = null;
        switch (studentApplicationExaminationPO.getCounselorPassed()) {
            case NOT_HANDLED:
                counselorPassed = "未处理";
                break;
            case REJECT_IN_MINUS:
                counselorPassed = "拒绝";
                break;
            case APPROVED:
                counselorPassed = "批准";
                break;
            default:
        }
        studentApplicationExaminationVO.setCounselorPassed(counselorPassed);

        studentApplicationExaminationVO.setDeptEmployee(studentApplicationExaminationPO.getDeptEmployee());
        studentApplicationExaminationVO.setDeptEmployeeText(studentApplicationExaminationPO.getDeptEmployeeText());

        String deptEmployeePassed = null;
        switch (studentApplicationExaminationPO.getDeptEmployeePassed()) {
            case NOT_HANDLED:
                deptEmployeePassed = "未处理";
                break;
            case REJECT_IN_MINUS:
                deptEmployeePassed = "拒绝";
                break;
            case APPROVED:
                deptEmployeePassed = "批准";
                break;
            default:
        }
        studentApplicationExaminationVO.setDeptEmployeePassed(deptEmployeePassed);

        studentApplicationExaminationVO.setAdmin(studentApplicationExaminationPO.getAdmin());
        studentApplicationExaminationVO.setAdminText(studentApplicationExaminationPO.getAdminText());

        String adminPassed = null;
        switch (studentApplicationExaminationPO.getAdminPassed()) {
            case NOT_HANDLED:
                adminPassed = "未处理";
                break;
            case REJECT_IN_MINUS:
                adminPassed = "拒绝";
                break;
            case APPROVED:
                adminPassed = "批准";
                break;
            default:
        }
        studentApplicationExaminationVO.setAdminPassed(adminPassed);

        return ResponseVO.success(studentApplicationExaminationVO);
    }
}
